package org.example.testcode.FactoryBean;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestFactoryBean {


    public static void main(String[] args) {

        AnnotationConfigApplicationContext annotationContext
                = new AnnotationConfigApplicationContext(MyConfig.class);

// 获取工厂类的bean

        Object bookFactoryBean = annotationContext.getBean("userMyFactoryBean");

        System.out.println(bookFactoryBean.getClass());

// 输出结果： class org.example.testcode.FactoryBean.User

//获取FactoryBean 本身 加 &符号

        Object bookFactoryBean1 = annotationContext.getBean("&userMyFactoryBean");

        System.out.println(bookFactoryBean1.getClass());

// 输出结果： class org.example.testcode.FactoryBean.MyFactoryBean

    }
}
